function myPromiseRace(promises){
    if(promises[Symbol.iterator] === undefined){
        return Promise.reject('param is not a iterator type');
    }
    promises = Array.from(promises);

    return new Promise((resolve,reject)=>{
        for(let promise of promises){
            promise.then(data=>{
                resolve(data);
            },err=>{
              reject(err);  
            })
        }
    })
}

let p1 = new Promise((reslove,reject)=>{
    reslove('p1');
}) 
let p2 = new Promise((reslove,reject)=>{
    reslove('p2');
}) 
let p3 = new Promise((reslove,reject)=>{
    reject('p3');
}) 

myPromiseRace([p3,p1,p1]).then(data=>{
    console.log(data)
},err=>{
    console.log(err);
})

